﻿namespace Whoot.DI
{
    public abstract class Facade<TService>
    {
        private static TService _that;
        private static bool _singleton;

        protected static TService That => HasInstance ? _that : Resolve();

        private static bool HasInstance => _singleton && _that != null;
        
        private static TService Resolve()
        {
            _singleton = Core.HasSingleton<TService>();
            return _that = Core.Get<TService>();
        }
    }
}